return ostree_repo_pull_one_dir (self, remote_name, NULL, refs_to_fetch, flags, progress, cancellable, error);
}
-/**
- * ostree_repo_pull_one_dir:
- *
- * Like ostree_repo_pull(), but supports pulling only a subpath.
- */
+/* Documented in ostree-repo.c */
gboolean
ostree_repo_pull_one_dir (OstreeRepo *self,
const char *remote_name,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
+{
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+
+ if (dir_to_pull)
+ g_variant_builder_add (&builder, "{s@v}", "subdir",
+ g_variant_new_variant (g_variant_new_string (dir_to_pull)));
+ g_variant_builder_add (&builder, "{s@v}", "flags",
+ g_variant_new_variant (g_variant_new_int32 (flags)));
+ if (refs_to_fetch)
+ g_variant_builder_add (&builder, "{s@v}", "refs",
+ g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch, -1)));
+
+ return ostree_repo_pull_with_options (self, remote_name, g_variant_builder_end (&builder),
+ progress, cancellable, error);
+}
+
+/* Documented in ostree-repo.c */
+gboolean
+ostree_repo_pull_with_options (OstreeRepo *self,
+ const char *remote_name,
+ GVariant *options,
+ OstreeAsyncProgress *progress,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
GHashTableIter hash_iter;
GKeyFile *config = NULL;
GKeyFile *remote_config = NULL;
char **configured_branches = NULL;
- gboolean is_mirror = (flags & OSTREE_REPO_PULL_FLAGS_MIRROR) > 0;
guint64 bytes_transferred;
guint64 end_time;
+ OstreeRepoPullFlags flags;
+ const char *dir_to_pull = NULL;
+ char **refs_to_fetch = NULL;
+ gboolean is_mirror;
+
+ if (options)
+ {
+ int flags_i;
+ (void) g_variant_lookup (options, "refs", "^a&s", &refs_to_fetch);
+ (void) g_variant_lookup (options, "flags", "i", &flags_i);
+ /* Reduce risk of issues if enum happens to be 64 bit for some reason */
+ flags = flags_i;
+ (void) g_variant_lookup (options, "subdir", "&s", &dir_to_pull);
+ }
if (dir_to_pull)
g_return_val_if_fail (dir_to_pull[0] == '/', FALSE);
+ is_mirror = (flags & OSTREE_REPO_PULL_FLAGS_MIRROR) > 0;
+
pull_data->async_error = error;
pull_data->main_context = g_main_context_ref_thread_default ();
pull_data->loop = g_main_loop_new (pull_data->main_context, FALSE);
ret = TRUE;
out:
- if (pull_data->main_context)
- g_main_context_unref (pull_data->main_context);
+ g_main_context_unref (pull_data->main_context);
if (pull_data->loop)
g_main_loop_unref (pull_data->loop);
g_strfreev (configured_branches);
"This version of ostree was built without libsoup, and cannot fetch over HTTP");
return FALSE;
}
+
+/**
+ * ostree_repo_pull_one_dir:
+ * @self: Repo
+ * @remote_name: Name of remote
+ * @dir_to_pull: Subdirectory path
+ * @refs_to_fetch: (array zero-terminated=1) (element-type utf8) (allow-none): Optional list of refs; if %NULL, fetch all configured refs
+ * @flags: Options controlling fetch behavior
+ * @progress: (allow-none): Progress
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * This is similar to ostree_repo_pull(), but only fetches a single
+ * subpath.
+ */
+gboolean
+ostree_repo_pull_one_dir (OstreeRepo *self,
+ const char *remote_name,
+ char **refs_to_fetch,
+ OstreeRepoPullFlags flags,
+ OstreeAsyncProgress *progress,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "This version of ostree was built without libsoup, and cannot fetch over HTTP");
+ return FALSE;
+}
+
+/**
+ * ostree_repo_pull_with_options:
+ * @self: Repo
+ * @remote_name: Name of remote
+ * @options: A GVariant a{sv} with an extensible set of flags.
+ * @progress: (allow-none): Progress
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Like ostree_repo_pull(), but supports an extensible set of flags.
+ * The following are currently defined:
+ *
+ * * subdir (s): Pull just this subdirectory
+ * * flags (i): An instance of #OstreeRepoPullFlags
+ * * refs: (as): Array of string refs
+ */
+gboolean
+ostree_repo_pull_with_options (OstreeRepo *self,
+ const char *remote_name,
+ GVariant *options,
+ OstreeAsyncProgress *progress,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "This version of ostree was built without libsoup, and cannot fetch over HTTP");
+ return FALSE;
+}
+
#endif
/**